package static_demo.static静态方法;

public class ArrayUtil {
    // 工具类 私有构造方法 防止创建对象
    private ArrayUtil() {
    }

    public static String printArr(int[] arr) {
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                sb.append(arr[i]);
            } else {
                sb.append(arr[i] + ", ");
            }
        }
        sb.append("]");
        return sb.toString();
    }

    public static double getAerage(double[] arr) {
        double num=0;
        for (int i = 0; i < arr.length; i++) {
            num += arr[i];
        }
        double averge = num / arr.length;
        return averge;
    }


}
